import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
// 富文本插件
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor, /* { default global options } */ )

Vue.component('tree-table', ZkTable)

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
    // 加入请求拦截器
axios.interceptors.request.use(config => {
        // config 请求的基本内容
        config.headers.Authorization = sessionStorage.getItem('token')
        return config
    })
    // 响应拦截器
axios.interceptors.response.use(res => {
    return res.data
})

// axios和vue无关,所以需要把axios挂载到vue的原型上
// 否则其它组件无法直接使用axios
Vue.prototype.axios = axios

Vue.config.productionTip = false

Vue.filter('dataFormat', (time) => {
    var date = new Date(time)
    var y = (date.getFullYear() + '').padStart(2, 0)
    var m = (date.getMonth() + 1 + '').padStart(2, 0)
    var d = (date.getDate() + '').padStart(2, 0)
    return `${y}-${m}-${d}`
})

new Vue({
    router,
    // 将App这个组件替换id为app的监管区域-->把App.vue看成是监管区域
    render: h => h(App)
}).$mount('#app')